﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class ModifyYCAnnotate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["userName"] == null || Session["roleID"] == null)
        {
            Response.Redirect("Login.aspx");
            Response.End();
        }
        else if (Session["roleID"].ToString() != "1")
        {
            Response.Write("<script language='javascript'>alert('你无权修改处理意见!');history.go(-1);</script>");
            Response.End();
        }

        if (!Page.IsPostBack)
        {
            if (Request.QueryString["ycid"] != null)
            {
                string YCID = Request.QueryString["ycid"].ToString();
                BindToRptAnnotate(YCID);
            }

        }
    }
    protected void BindToRptAnnotate(string tempYCID)
    {
        YCSteps YCS = new YCSteps();
        DataSet ds = YCS.GetAllStepsByYCID(tempYCID);
        DataView DV = ds.Tables[0].DefaultView;
        DV.RowFilter = "DEPID = 1";
        rptAnnotate.DataSource = DV;
        rptAnnotate.DataBind();
        lblYCID.Text = tempYCID; 
    }
    protected void rptAnnotate_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Update")
        {
            string YCID = lblYCID.Text.Trim();
            int stepID = Convert.ToInt32(e.CommandArgument);
            YCSteps YCS = new YCSteps(stepID, YCID);
            string annotate=BasicClass.HtmlEncode(((TextBox)(e.Item.FindControl("txtAnnotate"))).Text);
            YCS.Annotate = annotate;
            if (YCS.UpdateYCStep())
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('修改成功!');", true);


            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('发生未知错误，批注修改失败!');", true);
            }
            BindToRptAnnotate(YCID);
            
        }
    }
}
